<script type="text/javascript" src="/admins/js/jquery/jquery.PrintArea.js"></script>
<?php 
    if($this->ma == 1) {
        echo '<script language="javascript" type="text/javascript">alert("保存成功！");</script>';
    }
?>
<style>
    body{
        -webkit-print-color-adjust: exact;
    }
    #addcontent{
        font-size: 11px;
        width: 400px;
        float: left;
        border:1px dashed #000;
        margin-right: 20px;
    }
    #addcontent #stroe{
        margin-top: 15px;
        margin-left: 15px;
        float: left;
        width: 180px;
    }
    #addcontent #ucity{
        margin-top: 5px;
        margin-right: 15px;
        text-align: right;
        float: left;
        width: 180px;
        height: 40px;
        font-size: 14px;
    }
    #addcontent #useraddr{
        width:360px;
        margin-left: 15px;
        margin-top: 15px;
        float: left;
    }
    #addcontent #barcode{
        width: 370px;
        margin-left: 8px;
        margin-top: 15px;
        float: left;
        text-align: center;
        border:1px solid #000;
    }
    #addcontent #userdate{
        width: 380px;
        margin-top: 5px;
        margin-left: 8px;
        margin-bottom: 5px;
        float: left;
        border:1px solid #000;
    }
</style>
<form method="post" action="/admini/managewaybill/addform/id/<?php echo $this->billall->id; ?>" id="saveForm">
<div id="addcontent">
    <div id="stroe">FROM：TYBB</div>
    <div id="ucity"><?php echo $this->billall->UserCity->word;?><br></div>
    <div id="useraddr">
        &nbsp;To：<input type="text" id="con1" name="con1" value="<?php echo $this->billall->consignee;?>" onblur="javascript:prin('con1')"/><br>
        Tel：<input type="text" id="cte1" name="cte1" value="<?php echo $this->billall->conTel;?>" onblur="javascript:prin('cte1')"/><br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<textarea id="cad1" name="cad1" cols="40" rows="3" style="resize:none;" onblur="javascript:prin('cad1')"><?php echo $this->billall->conAdd;?></textarea><br>
        <input type="text" id="cpc1" name="cpc1" value="<?php echo $this->billall->conPostCode;?>" onblur="javascript:prin('cpc1')"/><br>
        <?php echo $this->billall->UserCity->ename.'('.$this->billall->UserCity->name.')';?>
    </div>
    <div id="barcode"><img src="/barcode/barcode.php?codebar=BCGcode39&text=<?php echo $this->billall->billNo;?>" alt="barcode" width="360px" height="72px"/></div>
    <div id="userdate"><span style="float: left;margin-left: 5px;"><?php echo $this->billall->user->storeno;?></span><span style="float: right;margin-right: 5px;"><?php echo date('m/d H:i:s');?></span></div>
    <input type="hidden" id="opAction" name="opAction" value="saveAddress" />
</div>
</form>
<div class="printadd">
    <style>
    body{
        -webkit-print-color-adjust: exact;
    }
    .printadd table{
        font-size: 11px;
        width: 300px;
        height: 300px;
        float: left;
        
    }
    .printadd #stroe{
        margin-top: 15px;
        margin-left: 15px;
        float: left;
        width: 120px;
    }
    .printadd #ucity{
        margin-top: 5px;
        margin-right: 15px;
        text-align: right;
        float: right;
        width: 100px;
        height: 40px;
        font-size: 14px;
    }
    .printadd #useraddr{
        
    }
    .printadd #barcode{
        width: 270px;
        margin-left: 8px;
        margin-top: 15px;
        float: left;
        text-align: center;
        border:1px solid #000;
        padding: 5px;
    }
    .printadd #userdate{
        width: 280px;
        margin-top: 5px;
        margin-left: 8px;
        margin-bottom: 5px;
        float: left;
    }
</style>
<table style="border:1px dashed #bbb;font-size: 11px;width: 300px;height: 280px;float: left;">
    <tr style="width:300px;height: 40px;">
        <td ><div id="stroe" style="margin-top: 15px;margin-left: 15px;float: left;width: 120px;">FROM：TYBB</div></td>
        <td><div id="ucity" style="margin-top: 5px;margin-right: 15px;text-align: right;float: right;width: 100px;height: 20px;font-size: 14px;"><?php echo $this->billall->UserCity->word;?></div>
        <div id="cae1" style="margin-top: 5px;margin-right: 15px;text-align: right;float: right;width: 150px;height: 20px;font-size: 14px;"><?php echo $this->agentId;?></div></td>
    </tr>
    <tr><td colspan="2" style="width:300px;height: 120px;line-height:18px;">
    <div id="useraddr" style="width:280px;margin-left: 15px;float: left;height: 120px;">
        <div style="border-bottom:1px solid #000;float: left;width:60px;">SHIP TO：</div><div id="con1" style="padding:0 0 5px 0;float: left;width:220px;"><?php echo $this->billall->consignee;?></div>
        <div style="border-bottom:1px solid #000;float: left;width:35px;">TEL：</div><div id="cte1" style="padding:0 0 5px 0;float: left;width:200px;"><?php echo $this->billall->conTel;?></div>
        <div id="cad1" style="padding:0 0 5px 0;width:280px;float: left;width:250px;"><?php echo $this->billall->conAdd;?></div>
        <div style="border-bottom:1px solid #000;float: left;width:90px;">POSTALCODE：</div><div id="cpc1" style="padding:0 0 5px 0;float: left;width:150px;font-size: 14px;"><?php echo $this->billall->conPostCode;?></div>
        <div style="float: left;width:190px;"><?php echo $this->billall->UserCity->ename.'('.$this->billall->UserCity->name.')';?></div>
    </div>
        </td></tr>
    <tr><td colspan="2">
    <div id="barcode" style="width: 270px; margin-left: 5px;margin-top: 15px;float: left;text-align: center;border:1px solid #000;padding: 5px;">
        <img src="/barcode/barcode.php?codebar=BCGcode39&text=<?php echo $this->billall->billNo;?>" alt="barcode" width="250px" height="42px" style="margin-left:2px"/>
        <span><?php echo $this->billall->billNo;?></span>
    </div>
    <div id="userdate" style=" width: 280px;margin-top: 5px; margin-left: 8px;margin-bottom: 5px; float: left;"><span style="float: left;margin-left: 5px;"><?php echo $this->billall->user->storeno;?></span><span style="float: right;margin-right: 5px;"><?php echo date('m/d H:i:s');?></span></div>
</td></tr>
</table>
</div>
<div style='padding-top:10px;padding-bottom: 5px;padding-left: 20px;float: left;width: 90%' id="div_button">
    <input type="button" id="refo" name="refo" value="返回" style="background-color: #1668A4;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;"/>
    <input type="button" id="save" name="save" value="保存" onClick="javascript:$('#saveForm').submit()" style="background-color: #F60;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;margin-left: 250px;"/>
    <input type="button" id="print" name="print" value="打印" style="background-color: #FF8312;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;margin-left: 250px;"/>
</div>
<script type="text/javascript">
    $("#refo").click(function(){
        location.href = "/admini/managewaybill/billaccep/id/<?php echo $this->billall->id;?>"; 
    });
    $('#div_button #print').click(function(){
         $.ajax({    
                type: 'POST',
                url: '/admini/managewaybill/isaddform/id/<?php echo $this->billall->id;?>',
                success: function(data) {
                    if(data == 2){
                        $("div.printadd").printArea(); 
                    }else{
                        alert("发生未知错误，请重新操作");
                        location.href = "/admini/managewaybill/addform/id/<?php echo $this->billall->id;?>";
                    }
                }
         });
    });
    function prin(name){
        var val = $("input#"+name).val();
        if(name == "cad1"){
            val = $('#addcontent #'+name).val();
        }
        $('#printadd div#'+name).text(val);
    }    
</script>

